// Fill out your copyright notice in the Description page of Project Settings.


#include "CharacterZD/Anim/ZDAnimNotify_SpawnBullet.h"

#include "PaperZDAnimInstance.h"
#include "Bullet/RuleBullet.h"
#include "CharacterZD/Core/RuleCharacterZD.h"
#include "Components/ArrowComponent.h"

void UZDAnimNotify_SpawnBullet::OnReceiveNotify_Implementation(UPaperZDAnimInstance* OwningInstance) const
{
	if (BulletClass == nullptr || OwningInstance == nullptr)
	{
		return;
	}
	
	
	if (ARuleCharacterZD* Character = Cast<ARuleCharacterZD>(OwningInstance->GetOwningActor()))
	{
		ARuleBullet* Bullet = Character->GetWorld()->SpawnActor<ARuleBullet>(BulletClass, Character->GetFirePoint()->GetComponentLocation(), Character->GetFirePoint()->GetComponentRotation());
		if (Bullet)
		{
			
		}
	}
}

FName UZDAnimNotify_SpawnBullet::GetDisplayName_Implementation() const
{
	if (BulletClass)
	{
		return FName(BulletClass->GetName());
	}
	return Super::GetDisplayName_Implementation();
}
